from django.db import models

class BookInfoManager(models.Manager):
    def create_book(self,title,pub_date):
        book = self.model()
        book.btitle = title
        book.bpub_date = pub_date
        book.bread=0
        book.bcommet=0
        book.isDelete = False
        return book

class BookInfo(models.Model):
    btitle = models.CharField(max_length=20)
    bpub_date = models.DateTimeField()
    bread = models.IntegerField(default=0)
    bcommet = models.IntegerField(default=0)
    isDelete = models.BooleanField(default=False)

    books = BookInfoManager()
    class Meta:
        db_table = 'bookinfo'

class HeroInfo(models.Model):
    hname = models.CharField(max_length=20)
    hgender = models.BooleanField(default=True)
    isDelete = models.BooleanField(default=False)
    hcontent = models.CharField(max_length=100)
    hbook = models.ForeignKey('BookInfo')

class AreaInfo(models.Model):
    atitle = models.CharField(max_length=500)
    aParent = models.ForeignKey('self', null=True, blank=True)
